<template>
  <div>
    <div class="hotwork">
          <ul>
              <li v-for="(apply,index) in myapply" :key="index">
                  <div class="job">
                      <span class="jobs">{{apply.jobs}}</span>
                    <span class="salary">{{apply.salary}}</span>
                    <a class="eduname">{{apply.eduname}}</a>
                  </div>
                  <div class="company">
                      <span class="companyname">{{apply.companyname}}</span>
                      <span class="reviewapply"><a>岗位回复：</a><el-tag class="tag">{{apply.reviewapply}}</el-tag></span>
                  </div>
                  <div class="btn" >
                      <el-button type="success" @click="RecruitDetail(apply)">查看详情</el-button>
                  </div>
              </li>
          </ul>
      </div>
      <div class="page">
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[1, 5, 8, 10]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      myapply:{},
      total:0,
      //获取分页列表的参数
      queryInfo:{
          pagenum:1,
          pagesize:5
      },

    }
  },
  created(){
    this.getYonghu()
  },
  methods:{
    async getYonghu() {
      this.user = JSON.parse(window.sessionStorage.getItem('user'))
      const { data: res } = await this.$http.get(
        'userByUsername?username=' + this.user.username
      )
      if (res.meta.status != 200) return this.$message.error(res.meta.msg)
      this.yonghu = res.data
      this.getMyApply()
    },
    //监听pagesize改变的事件
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize
      this.getYonghu()
    },
    //监听页码值改变的数据
    handleCurrentChange(newPage) {
      this.queryInfo.pagenum = newPage
      this.getYonghu()
    },
    async getMyApply(){
      const {data:res}=await this.$http.get("getAllApplyByUsername?username="+this.yonghu.username,{params:this.queryInfo})
      this.myapply=res.data.records
      this.total = res.data.total
      console.log(this.myapply);
    },
    async RecruitDetail(apply){
      console.log(apply);
        window.sessionStorage.setItem('place',apply.place)
        window.sessionStorage.setItem("Recruitid",apply.recruitid)
        this.$router.push("/RecruitDetail")

    }

  }

}
</script>

<style lang="less" scoped>
.hotwork{
    li{
        padding: 10px 0px 0 20px;
        list-style-type:none;
        background-color: pink;
        width: 91%;
        height: 145px;
        margin-bottom: 10px;
        background-color: #fff;
        border-radius: 10px;
        .job{
            margin-top: 15px;
            width: 25%;
        }
        .company{
            width: 45%;
        }
        .btn{
            float: right;
            padding-right: 85px;
            line-height: 130px;
            
        }
        .jobs{
            font-size: 23px;
            font-weight:700;
            display: block;
            margin-bottom: 10px;
        }
        .salary{
            font-size: 20px;
            font-weight:600;
            display: block;
            margin-bottom: 10px;
            color: red;
        }
        .eduname{
            font-size: 14px;
            margin-bottom: 10px;
            color: #7D6695;
            background-color: #F6F7F8;
            text-align: center;
            border-radius: 12px;
            padding:5px 8px 5px 8px;
        }
        .company{
            padding-left: 20px;
        }
        .companyname{
            font-size: 18px;
            margin: 22px 0 15px 0;
            font-weight:700;
        }
        .placename{
            color: #999999;
        }
        div{
            float: left;
        }
        span{
            display: block;
        }
        .reviewapply>a{
          float: left;

        }
        .tag{
          width: 100px;
          float: left;
        }

    }
    li:hover{
        box-shadow: 1px 1px 5px #888888;
    }
    el-pagination{
      margin-left: 20%;
    }
}
</style>